#ifndef AMANOFMAPSSTATE_H_INCLUDED
#define AMANOFMAPSSTATE_H_INCLUDED

#include "GameState.h"
#include <TGUI/TGUI.hpp>
#include "GameEngine.h"
#include <iostream>
#include <sstream>
#include "Tilemap.h"
#include "TextEntity.h"
#include "IntroState.h"
#include "Player.h"
#include "message.h"
#include "sidemenu.h"
#include "BottomMenu.h"
#include "Entity.h"
#include <vector>
#include <Box2D/Box2D.h>

class AManOfMapsState : public GameState
{
public:

    static b2World* world;  //physics world
    static std::vector<TestEntity*> EntityList;

	void Init(sf::RenderWindow& window);
	void Cleanup();

	void Pause();
	void Resume();


	void Events(GameEngine* game, sf::RenderWindow& window);
	void Update(GameEngine* game, sf::RenderWindow& window);
	void Render(GameEngine* game, sf::RenderWindow& window);

    //game utility methods
	void updateMessage(sf::String);
    void changeTime();
	bool load(const std::string&);

    //player action methods
	void explore();
	void camp();
	void lookCloser();
	void resetPlayer();
	float moveCost(sf::Vector2f);

    //map and camera methods
	void makeMap(int,int);
	void removeFog();
	void centerCamera();
	static int getMapListSize();
	sf::FloatRect getViewRect();
	void raytrace(int x0, int y0, int x1, int y1);

	void makeTestArray(sf::RenderWindow& window);

	static AManOfMapsState* Instance() {
		return &m_AManOfMapsState;
	}

    static int currentMap;

protected:
	AManOfMapsState() { }

private:

	static AManOfMapsState m_AManOfMapsState;


    sf::View view;
    sf::View view2;

    sf::Event event;

    tgui::Gui gui;

    sf::Font font;
    sf::Text text;

    std::vector<int> time;

    static std::vector<TileMap*> mapList;  //A vector of all the TileMaps in the game
    std::vector<int> mapRenderList; //not needed if only one map is displayed at a time

    Player* player;

    sf::Vector2f playerMoveDir;

    Message* mBox;
    sideMenu* sMenu;
    BottomMenu* bMenu;

    int playerTile;
    int tileSize;   //size of the map tiles (need to move into tile or map class)

    bool cameraCentered;

    float timeStep; //the length of time passed to simulate (seconds)
    int velocityIterations;   //how strongly to correct velocity
    int positionIterations;   //how strongly to correct position

    sf::RectangleShape viewRectangle;
    sf::RectangleShape mapRectangle;

    sf::Texture m_tileset;

    int energyDrain;

    float moveDistance;

    sf::Vector2f playerStartPos;
    int startMap = 1;   //ID of the map where th player starts

    sf::VertexArray testArray1;
    std::vector<sf::Vector2f> lights;

    sf::VertexArray testPoints;
    sf::RectangleShape testRect;
};



#endif // AMANOFMAPSSTATE_H_INCLUDED
